/* 
 * File:   Socket.h
 * Author: Lance
 *
 * Created on September 13, 2012, 9:09 PM
 */

#ifndef SOCKET_H
#define	SOCKET_H

#include <string>
#include "HTTPRequest.h"
#include "HTTPResponse.h"
#include <fstream>
#include <iostream>
#include <arpa/inet.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <iostream>

using namespace std;

class Socket {
public:
	Socket(string host, int port);
	Socket(const Socket& orig);
	virtual ~Socket();
	void sendRequest(HTTPRequest * request);
	HTTPResponse * getResponseHeader();
	HTTPResponse * getResponse();
	void closeSocket();
private:
	int port, s_handle;
	const char * ipAddress;
	struct sockaddr_in server;
	const char * dns(string host);
	bool noBlankLine(string response);
};

#endif	/* SOCKET_H */

